package com.probiz.estore.common.model.content.base;

import java.io.Serializable;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

import com.probiz.estore.core.model.BaseObject;

/**
 * ContentMedia Base Java Bean, base class for the model, mapped directly to database table
 * 
 * Avoid changing this file if not necessary, will be overwritten. 
 *
 */
public class ContentMediaTbl extends BaseObject implements Serializable {

    protected Integer contentMediaId;
	protected String mediaDescription;
	protected Short mediaType;
	protected String mediaUrl;
	protected Integer sortOrder;
	protected com.probiz.estore.common.model.content.Content content;


	/**
	 * Default Empty Constructor for class ContentMedia
	 */
	public ContentMediaTbl () {
		super();
	}
	
	/**
	 * Default Key Fields Constructor for class ContentMedia
	 */
	public ContentMediaTbl (
		 Integer in_contentMediaId
        ) {
		this.setContentMediaId(in_contentMediaId);
    }

	
	public com.probiz.estore.common.model.content.Content getContent () {
		return content;
	}	
	
	public void setContent (com.probiz.estore.common.model.content.Content in_content) {
		this.content = in_content;
	}
    

	/**
	 * 	 * @return Integer
     * @hibernate.id column="contentMediaId" type="java.lang.Integer" generator-class="native"
	 */
	public Integer getContentMediaId() {
		return this.contentMediaId;
	}
	
	/**
	 * Set the contentMediaId
	 */	
	public void setContentMediaId(Integer aValue) {
		this.contentMediaId = aValue;
	}	

	/**
	 * 	 * @return Integer
	 */
	public Integer getContentId() {
		return this.getContent()==null?null:this.getContent().getContentId();
	}
	
	/**
	 * Set the contentId
	 */	
	public void setContentId(Integer aValue) {
	    if (aValue==null) {
	    	content = null;
	    } else {
	        content = new com.probiz.estore.common.model.content.Content(aValue);
	        content.setVersion(Integer.valueOf(0));//set a version to cheat hibernate only
	    }
	}	

	/**
	 * 	 * @return String
	 * @hibernate.property column="mediaDescription" type="java.lang.String" length="256" not-null="false" unique="false"
	 */
	public String getMediaDescription() {
		return this.mediaDescription;
	}
	
	/**
	 * Set the mediaDescription
	 */	
	public void setMediaDescription(String aValue) {
		this.mediaDescription = aValue;
	}	

	/**
	 * 0表示更多图片，1表示附件	 * @return Short
	 * @hibernate.property column="mediaType" type="java.lang.Short" length="5" not-null="false" unique="false"
	 */
	public Short getMediaType() {
		return this.mediaType;
	}
	
	/**
	 * Set the mediaType
	 */	
	public void setMediaType(Short aValue) {
		this.mediaType = aValue;
	}	

	/**
	 * 	 * @return String
	 * @hibernate.property column="mediaUrl" type="java.lang.String" length="255" not-null="false" unique="false"
	 */
	public String getMediaUrl() {
		return this.mediaUrl;
	}
	
	/**
	 * Set the mediaUrl
	 */	
	public void setMediaUrl(String aValue) {
		this.mediaUrl = aValue;
	}	

	/**
	 * 	 * @return Integer
	 * @hibernate.property column="sortOrder" type="java.lang.Integer" length="10" not-null="false" unique="false"
	 */
	public Integer getSortOrder() {
		return this.sortOrder;
	}
	
	/**
	 * Set the sortOrder
	 */	
	public void setSortOrder(Integer aValue) {
		this.sortOrder = aValue;
	}	

	/**
	 * @see java.lang.Object#equals(Object)
	 */
	public boolean equals(Object object) {
		if (!(object instanceof ContentMediaTbl)) {
			return false;
		}
		ContentMediaTbl rhs = (ContentMediaTbl) object;
		return new EqualsBuilder()
				.append(this.contentMediaId, rhs.contentMediaId)
						.append(this.mediaDescription, rhs.mediaDescription)
				.append(this.mediaType, rhs.mediaType)
				.append(this.mediaUrl, rhs.mediaUrl)
				.append(this.sortOrder, rhs.sortOrder)
				.isEquals();
	}

	/**
	 * @see java.lang.Object#hashCode()
	 */
	public int hashCode() {
		return new HashCodeBuilder(-82280557, -700257973)
				.append(this.contentMediaId) 
						.append(this.mediaDescription) 
				.append(this.mediaType) 
				.append(this.mediaUrl) 
				.append(this.sortOrder) 
				.toHashCode();
	}

	/**
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		return new ToStringBuilder(this)
				.append("contentMediaId", this.contentMediaId) 
						.append("mediaDescription", this.mediaDescription) 
				.append("mediaType", this.mediaType) 
				.append("mediaUrl", this.mediaUrl) 
				.append("sortOrder", this.sortOrder) 
				.toString();
	}

	/**
	 * Return the name of the first key column
	 */
	public String getFirstKeyColumnName() {
		return "contentMediaId";
	}
	
	/**
	 * Return the Id (pk) of the entity, must be Integer
	 */
	public Integer getId() {
		return contentMediaId;
	}

}